using System;
using System.Collections.Generic;

namespace StrategyGame.Scripts
{
    public static class RandomExtensions
    {
        public static T GetRandomItem<T>(this Random random, IList<T> list)
        {
            return list.Count == 0 ? default(T) : list[random.Next(0, list.Count)];
        }
        public static T RemoveRandomItem<T>(this Random random, IList<T> list)
        {
            if (list.Count == 0) return default(T);
            int i = random.Next(0, list.Count);
            T item = list[i];
            list.RemoveAt(i);
            return item;
        }
    }
}
